<%--
  Created by IntelliJ IDEA.
  User: Q倘若
  Date: 2021/2/11
  Time: 16:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>ajax2</title>
    <script src="${pageContext.request.contextPath}/statics/js/jquery-3.4.1.min.js"></script>
    <script>
        $(function () {
            /*
        * $.post(url,param[可选],success)
        * */
            $("#btn").click(function () {
                $.post("${pageContext.request.contextPath}/a2",function (data) {
                    console.log(data);
                    var html="";
                    for(let i=0;i<data.length;i++){
                        html+="<tr>"+"<td>"+data[i].id+"</td>"+
                            "<td>"+data[i].name+"</td>"+
                            "<td>"+data[i].age+"</td>"
                            "</tr>"
                    }

                    $("#context").html(html);
                });
            });
        });

    </script>
</head>
<body>
    <input type="button" id="btn" value="加载数据" />
    <table>
        <tr>
            <td>学号</td>
            <td>姓名</td>
            <td>年龄</td>
        </tr>
        <tbody id="context"></tbody>
    </table>
</body>
</html>
